package com.internship.util;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class StringUtil {

	private static StringUtil single=null;  
    public final static String APP_KEY = "p5tvi9dstuvl4";
    public final static String APP_SECRET = "A3ZLhB0GymY7";
    
    private  long TOURIST = 1000000;
    
    public static synchronized StringUtil getInstance() {  
         if (single == null) {    
             single = new StringUtil();  
         }    
        return single;  
}  
    public long getTourist(){
    	return TOURIST;
    }
    public void setTourist(long num){
    	TOURIST = num;
    }
    
    public static String getStrDateTime() {
    	Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	return format.format(new Date());
    }
    
    public static String getStrDate() {
    	Format format = new SimpleDateFormat("yyyy-MM-dd");
    	return format.format(new Date());
    }
    
    public static String getPreDayDate(int reduceDay) {
    	Date dnow = new Date();
    	Date dPre = new Date();
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(dnow);
    	calendar.add(Calendar.DAY_OF_MONTH, -reduceDay);
    	dPre = calendar.getTime();
    	
    	Format format = new SimpleDateFormat("yyyy-MM-dd");
    	return format.format(dPre);
    }
    public static boolean isEmpty(String data){
    	if (null == data || data.equals("")) {
			return true;
		}
    	return false;
    }
    public static String[] getCurrentGrades() {
		Calendar calendar = Calendar.getInstance();
		int currentYear = calendar.get(Calendar.YEAR);
		String[] array = new String[] { String.valueOf(currentYear - 1),
				String.valueOf(currentYear - 2),
				String.valueOf(currentYear - 3),
				String.valueOf(currentYear - 4),
				String.valueOf(currentYear - 5)};
		return array;
	}
    public static String bz(Date date) {
    	SimpleDateFormat format  =new SimpleDateFormat(
				"yyyy-MM-dd", new Locale("CHINESE", "CHINA"));
		
    	return format.format(date);
    }
	public static void main(String[] args){ 
    		/*Long val ;
    		int size;
    		StringBuilder sb = new StringBuilder("");     
    		sb.append(val);      
    		if (sb.length() < size){        
    			int cnt = size - sb.length();         
    			for (int i = 0; i < cnt; i++){        
    				sb.insert(0, "0");           
    				}      
    			return sb.toString();     
    			
    			}else if (sb.length() > size){  
    				
    				return sb.substring(sb.length() - size, size);  
    				}else{ 
    					
    					return sb.toString();       
    				}  
    		}    
	//生成4位流水号：0001——XXXX       
    	for(int i=1;i<=Integer.parseInt(boxCount);i++){     
    		
    		SCMPackInfo packInfo = new SCMPackInfo();          
    		String  boxNumber=deliverNoticeCode+fmtLong(Long.valueOf(i),4);    
    		packInfo.setBoxNumber(boxNumber);            
    		packInfo.setBoxAmount(1.0);            
    		packInfo.setDeliverNotice(deliverNotice);   
    		this.entityManager.save(packInfo);        
    				} */

}}
